package uiLayer;
import modelLayer.*;
import controlLayer.*;
import java.util.Scanner;

public class MainMenuUI {
    private CustomerUI customer;
    private EmployeeUI employee;
    private ProductUI product;
    private OrderUI order;
    private StatisticsUI stats;
    private MachineUI machine;
    private RentUI rent;
    
    public MainMenuUI () {
        customer = new CustomerUI();
        employee = new EmployeeUI();
        product = new ProductUI();
        order = new OrderUI();
        stats = new StatisticsUI();
        machine = new MachineUI();
        rent = new RentUI();
    } 
    
    public void start() {
        mainMenu();
    } 
    
    /**
     * Main menu methods
     **/
    private void mainMenu() {
        boolean stop = false;
        
        while(!stop) {
            int choice = writeMainMenu();
            
            switch(choice) {
            case 1 : customer.customersMenu();
                break;
            case 2 : employee.employeesMenu();
                break;
            case 3 : product.productsMenu();
                break;
            case 4 : order.orderMenu();
                break;
            case 5 : stats.statisticsMenu();
                break;
            case 6 : machine.machinesMenu();
                break;
            case 7 : rent.rentMenu();
                break;    
            case 0 : System.out.println("The system will stop");
                     stop = true;
                break;
            default : System.out.println("Invalid command");
                      pause();
                      stop = true;
                break;
            }
        }
    }
    
    private int writeMainMenu() {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("\f*** Main Menu ***");
        System.out.println("1. Customers");
        System.out.println("2. Employees ");
        System.out.println("3. Product ");
        System.out.println("4. Orders ");
        System.out.println("5. Statistics ");
        System.out.println("6. Machines ");
        System.out.println("7. Rents ");
        System.out.println("0. Close ");
        System.out.println("\n Type your choice (numeric)");
        
        int choice = keyboard.nextInt();
        
        return choice;
    }
    
    public static void pause()
    {
         Scanner keyboard = new Scanner(System.in);
         System.out.println("Enter to continue");
         String address = keyboard.nextLine();
    }
    
}
